package com.zjhn.ds.controller.app.md;

import com.alibaba.fastjson.JSON;
import com.zjhn.ds.common.BizResult;
import com.zjhn.ds.domain.dto.app.AppStationMonitorDto;
import com.zjhn.ds.domain.dto.app.CurrentTaskDto;
import com.zjhn.ds.domain.dto.app.QueueTaskDto;
import com.zjhn.ds.param.AppStationMonitorParam;
import com.zjhn.ds.param.FinishTaskParam;
import com.zjhn.ds.param.ReportParam;
import com.zjhn.ds.param.SwipeCardParam;
import com.zjhn.ds.service.AppStationMonitorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @BelongsProject: ds_jlw
 * @BelongsPackage: com.zjhn.ds.controller.app
 * @Author: sxt
 * @CreateTime: 2023-10-08  16:29
 * @Description:
 * @Version: 1.0
 */
@Slf4j
@RestController
@RequestMapping("/jlw/app/monitor")
@Api(tags = "app机台监控接口")
public class AppStationMonitorController {

    @Resource
    private AppStationMonitorService appStationMonitorService;

    @ApiOperation("app机台监控页面数据")
    @PostMapping("/stationMonitor")
    public BizResult<List<AppStationMonitorDto>> stationMonitor(@RequestBody @Valid AppStationMonitorParam param) {
        log.info("====[INFO]========AppStationMonitorController====stationMonitor param:{}", JSON.toJSONString(param));
        return appStationMonitorService.stationMonitor(param);
    }

    @ApiOperation("app获取工位当前刷卡任务")
    @GetMapping("/currentTask")
    public BizResult<CurrentTaskDto> currentTask(@RequestParam("station_id") String stationId) {
        log.info("====[INFO]========AppStationMonitorController====currentTask stationId:{}", stationId);
        return appStationMonitorService.currentTask(stationId);
    }

    @ApiOperation("app获取工位排队任务")
    @GetMapping("/queueTask")
    public BizResult<List<QueueTaskDto>> queueTask(@RequestParam("station_id") String stationId) {
        log.info("====[INFO]========AppStationMonitorController====queueTask stationId:{}", stationId);
        return appStationMonitorService.queueTask(stationId);
    }

    @ApiOperation("app确认报工")
    @PostMapping("/report")
    public BizResult<?> report(@RequestBody @Valid ReportParam param) {
        log.info("====[INFO]========AppStationMonitorController====report param:{}", JSON.toJSONString(param));
        return appStationMonitorService.report(param);
    }

    @ApiOperation("app刷卡")
    @PostMapping("/swipeCard")
    public BizResult<?> swipeCard(@RequestBody @Valid SwipeCardParam param) {
        log.info("====[INFO]========AppStationMonitorController====swipeCard param:{}", JSON.toJSONString(param));
        return appStationMonitorService.swipeCard(param);
    }

    @ApiOperation("app派工任务完成")
    @PostMapping("/finishTask")
    public BizResult<?> finishTask(@RequestBody @Valid FinishTaskParam param) {
        log.info("====[INFO]========AppStationMonitorController====finishTask param:{}", JSON.toJSONString(param));
        return appStationMonitorService.finishTask(param);
    }


}
